﻿<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="Datagility.Shpt.SPDocMirror.UI.MirrorSettingsAction" 
                Location="CommandUI.Ribbon.ListView" 
                RegistrationId="101" 
                RegistrationType="List" 
                Title="Library Mirroring Settings">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.Library.Settings.Controls._children">
          <Button Id="Datagility.Shpt.SPDocMirror.UI.MirrorSettingsAction" 
                  Command="MirrorSettingsCommand" 
                  Description="Library Mirroring Settings" 
                  LabelText="Mirroring Settings"
                  Image32by32="/_layouts/images/Datagility.Shpt.SPDocMirror.UI/mirror_32.png"
                  Image16by16="/_layouts/images/Datagility.Shpt.SPDocMirror.UI/mirror_16.png"
                  TemplateAlias="o2" 
                  Sequence="93"/>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="MirrorSettingsCommand" 
                          CommandAction="javascript:
          var listId = SP.ListOperation.Selection.getSelectedList();
          
          var options = SP.UI.$create_DialogOptions();
          options.url = SP.Utilities.Utility.getLayoutsPageUrl('Datagility.Shpt.SPDocMirror.UI/MirrorSettingsPage.aspx');
          options.url += '?listid=' + listId;
          options.width = 400;
          options.height = 200;
          options.title = 'Library Mirroring Settings';
  
          options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
          SP.UI.ModalDialog.showModalDialog(options);

          function CloseCallback(result, target)
          {
            if(result === SP.UI.DialogResult.OK)
            {
              alert('You clicked OK');
            }
            else if (result == SP.UI.DialogResult.cancel)
            {
              alert('You clicked Cancel');
            }
            //alert('Target is: ' + target);
          }"
        />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
  <CustomAction Id="MirrorSettingsSiteAction" 
                GroupId="SiteAdministration" 
                Location="Microsoft.SharePoint.SiteSettings" 
                Sequence="1000" 
                Title="Library Mirroring settings">
    <UrlAction Url="/_layouts/Datagility.Shpt.SPDocMirror.UI/MirrorMainSettingsPage.aspx"/>
  </CustomAction>
</Elements>
